#!/bin/bash

SrcDir=$1
DstDir=$2

Frac=3

for DirName in $SrcDir/*; do
    if [ -d $DirName ];then
        echo "Ready to Select Sample Images in Folder:$DirName"
        BaseDirName=`basename $DirName`
	FullDstDir=$DstDir/$BaseDirName
	echo "Make the Target Folder:$FullDstDir"
	mkdir $FullDstDir

	echo "Copying Files from Source Folder to The Target Folder..."
        counter=0
        for FileName in $DirName/*.JPG; do
	    counter=$[$counter+1]
	    if [ $[$counter%$Frac] -eq 0 ];then
		FullFileName=$FullDstDir/`basename $FileName`
		cp $FileName $FullFileName 
            fi
        done
    fi
done
